﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.OleDb;

namespace WebApplication1
{
    public partial class MenuDuSoir : System.Web.UI.Page
    {
        protected const string connectionString = @"Provider=SQLOLEDB;server=FORMA1614;Database=magicrecettes;User ID=magicrecettes;Password=cook;Trusted_Connection=False";
         //
      

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
   
                lblLogin.Text =  (String)Session["login"];
             string query = "SELECT distinct id_recette,nom,tps_preparation+tps_cuisson as tps_total,cout,difficulte FROM Recette " +
            "left join composition on id_recette=recette_id where ingredient_id in " +
            "(select ingredient_id from Ingredient_Menage left join Menage on Id_Menage = menage_id where login='" + lblLogin.Text + "')";


                OleDbDataAdapter da = new OleDbDataAdapter(query, connectionString);
                da.TableMappings.Add("Table", "Recette");

                DataSet ds = new DataSet();
                da.Fill(ds);

                Session["RECETTE"] = ds;
                
               
                grvMenuDuSoir.DataSource = ds;
                grvMenuDuSoir.DataBind();
            }
        }

        protected void grvMenuDuSoir_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

    }
}